package com.zcyr.core.sql;

import com.alibaba.druid.sql.dialect.postgresql.parser.PGLexer;
import com.alibaba.druid.sql.parser.Keywords;
import com.alibaba.druid.sql.parser.SQLParserFeature;
import com.alibaba.druid.sql.parser.Token;

import java.util.HashMap;
import java.util.Map;

/**
 * opengauss的词法解析器, 大多数依赖pgsql
 */
public class OGLexer extends PGLexer {
    public final static Keywords DEFAULT_OG_KEYWORDS;

    static {
        // 加入opengauss关键字
        Map<String, Token> map = new HashMap<>(DEFAULT_PG_KEYWORDS.getKeywords());
        map.put("PASSWORD", Token.PASSWORD);
        map.put("IDENTIFIED", Token.IDENTIFIED);
        DEFAULT_OG_KEYWORDS = new Keywords(map);
    }
    public OGLexer(String input, SQLParserFeature... features) {
        super(input, features);
        super.keywods = DEFAULT_OG_KEYWORDS;
    }
}
